/*
**
** Copyright @ 2020 Joshua Branson <jbranso@member.fsf.org>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or (at
** your option) any later version.
**
** It is distributed in the hope that it will be useful, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <math.h>

#define DOUBLE(x) ((x) * (x))

struct x_y_point
{
  float x, y; 
};

double get_distance (struct x_y_point a, struct x_y_point b)
{
  return (float) sqrtf (DOUBLE (fabsf (a.x - b.x)) + DOUBLE (fabsf (a.y - b.y))); 
}

int main ()
{
  /* struct x_y_point a = { 0.0, 0.0 }; */
  /* struct x_y_point b = { 1.0, 0.0 };  */

  struct x_y_point a;
  struct x_y_point b;

  a.x = 0.0;
  a.y = 0.0;

  b.x = 0.0;
  b.y = 1.0;

  double distance = get_distance (a, b);

  printf ("Distance between two points is %f\n", distance);
  
  return 0;
}
